<template>
	<view class="container">
		<view class="custom-search-border">
			<view>
				<view class="uni-slect-view">
					<uni-row :gutter="2" class="uni-row-select">
						<uni-col :span="6">
							<view class="uni-select-col">
							<uni-data-select
								v-model="teamValue"
								placeholder="班组"
								:localdata="teamList"
								:clear="false"
								@change="teamChange"
							></uni-data-select>
							</view>
						</uni-col>
						<uni-col :span="18">
							<view class="uni-select-col">
							<uni-data-select
								:key="selectKey"
								v-model="formData.filterTime"
								placeholder="日期"
								:localdata="dateList"
								:clear="false"
								@change="dateChange"
							></uni-data-select>
							</view>
						</uni-col>
					</uni-row>
				</view>
				<view class="line-main">
						<view class="line-box">
							<view
								:class="[
									'line-item',
									item.name == curType.name ? 'active' : '',
								]"
								v-for="(item, key) in tabList"
								:key="key"
								@click="onClickLine($event, item, key)"
							>
								{{ item.name }}
							</view>
						</view>
						<view 
							v-if="timeList!=''" class="line-box" style="margin-top: 5px;">
							<view
								:class="[
									'line-item',
									timeKey == curData ? 'active' : '',
								]"
								v-if="item != null"
								v-for="(item, timeKey) in timeList"
								:key="timeKey"
								:data-time="item"
								@click="onClickTime($event, item, timeKey)"
							>
								{{ item }}
							</view>
					</view>
				</view>
			</view>
			</view>
				
		<!-- <view style="height: 37px;">
			<uni-row  :gutter="12">
				<uni-col :span="24">
					<uni-forms :modelValue="formData">
						<uni-forms-item label="周期筛选:">
							<uni-data-select
								:key="selectKey"
								v-model="formData.filterTime"
								placeholder="日期"
								:localdata="dateList"
								:clear="false"
								@change="dateChange"
							></uni-data-select>
						</uni-forms-item>
					</uni-forms>
				</uni-col>
			</uni-row> -->
		<!-- </view> -->
		<!-- 项目列表 -->
		<scroll-view class="scroll-view" scroll-y="true">
			<view class="project-list" v-show="curType.name != '签名'">
				<view style="text-align: center;">
					<view class="project-list-value">
						<uni-icons
							type="camera-filled"
							size="54"
							color="#405ee0"
							@click="
								handlePhoto(
									detail,
									projectIndex,
									detailIndex,
								)
							"
						></uni-icons>
						<text :style="{ color: '#405ee0' }">
							{{
								taskImageList && taskImageList.imageList
									? taskImageList.imageList.length
									: 0
							}}
						</text>
					</view>
				</view>
				<view
					v-for="(project, projectIndex) in dataSource"
					:key="projectIndex"
					class="project-item"
				>
					<view>
						<uni-row :gutter="10">
							<uni-col :span="24">
								<view class="header-title">
									点检部位：{{ project.inspectionLocation }}
								</view>
							</uni-col>
						</uni-row>
						<view style="margin-top: 10px;">
							<uni-row :gutter="10" v-if="!project.valueNumVoList[0].isEditable">
								<uni-col :span="8">
									<view class="project-item-left">
										点检方式：{{ project.itemMethod }}
									</view>
								</uni-col>
								<uni-col :span="8">
									<view class="project-item-right">
										巡检周期：{{ project.periodicInfo }}
									</view>
								</uni-col>
								<uni-col :span="8">
									<view class="project-item-error">
										异常未处理！
									</view>
								</uni-col>
							</uni-row>
							<uni-row :gutter="10" v-if="project.valueNumVoList[0].isEditable">
								<uni-col :span="12">
									<view class="project-item-left">
										点检方式：{{ project.itemMethod }}
									</view>
								</uni-col>
								<uni-col :span="12">
									<view class="project-item-right">
										巡检周期：{{ project.periodicInfo }}
									</view>
								</uni-col>
							</uni-row>
							<uni-row>
								<view class="project-code-row">
									<uni-col :span="6">
										<view class="project-code-left">巡检结果：</view>
									</uni-col>
									<uni-col :span="14">
										<uni-data-select
											v-model="project.valueNumVoList[0].value"
											placeholder="请选择巡检结果"
											:localdata="xjtypeList"
											:disabled='!project.valueNumVoList[0].isEditable'
											@change="selectChange()"
										></uni-data-select>
									</uni-col>
									<uni-col :span="3" v-if="project.valueNumVoList[0].value === '2' || project.valueNumVoList[0].value === '4'">
										<view class="project-code-value">
											<uni-icons
												type="camera-filled"
												size="35"
												color="red"
												@click="
													abnormalPhoto(
														project,
														projectIndex,
														detailIndex,
													)
												"
											></uni-icons>
											<text :style="{ color: 'red' }">
												{{
													project.errImages && project.errImages
														? project.errImages.length
														: 0
												}}
											</text>
										</view>
									</uni-col>
								</view>
							</uni-row>
						</view>
					</view>
				</view>
				<view style="margin-bottom: 50px;">
					<view class="uni-project-item">
						<uni-row>
							<uni-col :span="6">
								<view class="project-code">异常说明： </view>
							</uni-col>
							<uni-col :span="18">
								<uni-easyinput type="textarea" v-model="abnormalDesc" placeholder="请输入异常说明"/>
							</uni-col>
						</uni-row>
					</view>
				</view>
			</view>
			<view class="project-list" v-show="curType.name === '签名'">
				<view
					v-for="(project, projectIndex) in signatureList"
					:key="projectIndex"
					class="project-item">
					<uni-row :gutter="10">
						<uni-col :span="24">
							<view class="header-title">{{ project.signatureItemName }}</view>
						</uni-col>
					</uni-row>
					<view style="margin-top: 10px;">
						<uni-row :gutter="10">
							<uni-col :span="14">
								<view class="project-info">
									<view class="project-item-left">签名周期：{{ project.freName }}</view>
									<view class="project-view-left">签名状态：<uni-tag class="header-tag" style="margin-left: 10px;" :text="project.statusName" :type="project.statusName === '已签' ? 'success': 'warning'"/></view>
									<view class="project-item-left">签名人：{{ project.signatoryPeopleName || '-' }}</view>
								</view>
							</uni-col>
							<uni-col :span="10">
								<image style="width: 100px;height: 50px;" :src='project.signImage'></image>
							</uni-col>
						</uni-row>
					</view>
					<uni-row :gutter="10">
						<uni-row v-if="project.loginPermissionName === '车间主任' && project.loginPermissionName === project.signatureRoleName">
							<uni-col :span="4">
								<view class="project-view-left">评语：</view>
							</uni-col>
							<uni-col :span="20">
								<uni-easyinput :disabled="project.statusName === '已签'" type="textarea" v-model="project.commentDesc" placeholder="请输入评语"/>
							</uni-col>
						</uni-row>
						<view class="project-code" style="margin-top: 5px;">
							<button
								style="font-size: 14px;"
								:disabled="!(project.loginPermissionName === project.signatureRoleName && project.statusName === '未签')"
								:class="{ 'disabled-button': !(project.loginPermissionName === project.signatureRoleName && project.statusName === '未签') }"
								type="default"
								@click="handleSignature(project,projectIndex,'')">签名</button>
						</view>
					</uni-row>
				</view>
				<view style="height: 50px;"></view>
			</view>
		</scroll-view>

		<!-- 底部按钮 -->
		<view class="bottom-btn" v-if="dataSource.length > 0 && curType.name != '签名'">
			<button
				:loading="btnLoading"
				:disabled="btnLoading"
				size="mini"
				type="default"
				@click="handleStore"
			>
				取消 
			</button>
			<button
				:loading="btnLoading"
				:disabled="btnLoading"
				size="mini"
				type="primary"
				@click="handleSave"
			>
				提交
			</button>
		</view>
		<view class="bottom-btn" v-if="signatureList.length > 0 && curType.name === '签名'">
			<button
				:loading="btnLoading"
				:disabled="btnLoading"
				size="mini"
				type="default"
				@click="qianmingStore"
			>
				取消
			</button>
			<button
				:loading="btnLoading"
				:disabled="btnLoading"
				size="mini"
				type="primary"
				@click="qianmingSave"
			>
				提交
			</button>
		</view>

		<!-- 空状态 -->
		<!-- <view v-if="dataSource.length === 0 && curType.name != '签名'">
			<empty-block></empty-block>
		</view> -->
	</view>
</template>

<script>
import dayjs from 'dayjs';
import { post, postForm } from '@/utils/request';
import { getDeviceCheckDetail, getDeviceInspect, submitDevicetask, submitDevicesign } from '@/api/check.js';
export default {
	name: '',
	data() {
		return {
			selectKey: 0,
			filterTime: '',
			updataTime: 0,
			copydataSource: [],
			copytaskImageList: {},
			copyabnormalDesc: {},
			imgUrl: '',
			allCopySign: [],
			changeTab: true,
			taskImageList: {
				imageList: []
			},
			permissionType: '',
			tabList: {},
			timeList: {},
			queryParams: {
				dateStr: 1,
			},
			abnormalDesc: '',
			allCopyData: {},
			teamValue: 0,
			teamList: [
				{
					text: '班组',
					value: 0
				},
				{
					text: '全部',
					value: 1
				}
			],
			dateList: [],
			editAble: true,
			xjtypeList: [
				{
					value: '1',
					text: '正常',
				},
				{
					value: '2',
					text: '异常',
				},
				{
					value: '4',
					text: '设备停机、检修、定修',
				},
			], // 将存储日期数据
			curType: {
				name: '日常点检',
				code: '日',
			},
			curData: {
				name: '日',
				code: '1',
			},
			activeIndex: -1,
			dataSource: [],
			dataSourceMap: {
				rcdjCheckList: [],
				zydjCheckList: [],
				shydjCheckList: [],
			},
			signatureList: [],
			deviceDataSource: [],
			taskDataList: {},
			formData: {},
			btnLoading: false,
			executedNum: 0,
			executeTotalNum: 0,
		};
	},
	/* watch: {
		dataSource: {
			handler(newVal, oldVal) {
					if(newVal.length>0  &&  oldVal.length>0) {
						this.changeTab = false
					}
				
			},
			deep: true
		},
		taskImageList: {
			handler(newVal, oldVal) {
				if(newVal.imageList!=null && oldVal.imageList!=null) {
				if(newVal.imageList.length>0  &&  oldVal.imageList.length>0) {
					this.changeTab = false
				}
				}
			},
			deep: true
		},
		abnormalDesc: function(newVal, oldVal) {
				if(newVal !=''  &&  oldVal !=''  ) {
					this.changeTab = false
				}
		},
	}, */
	watch: {
	},
	computed: {
		deviceColumns() {
			return [
				{ label: '区域编码', prop: 'areaCode' },
				{ label: '区域名称', prop: 'areaName' },
				{ label: '计划执行日期', prop: 'planExecuteDate' },
			];
		},
	},
	onLoad(option) {
		this.formData = JSON.parse(option.data);
		this.deviceDataSource = [this.formData];
		//this.generateDateList();
		this.getFilter()
		//this.getList();
	},
	methods: {
		generateDateList() {
			// 获取当前月份的天数
			const daysInMonth = dayjs().daysInMonth();

			// 生成日期列表
			this.dateList = Array.from({ length: daysInMonth }, (_, i) => {
				const day = i + 1;
				// 格式化为两位数，如 1 → '01'
				const formattedDay = day < 10 ? `0${day}` : `${day}`;
				return {
					value: formattedDay,
					text: formattedDay,
				};
			});

		},
		resetData() {
			setTimeout(()=> {
				
				this.formData.filterTime = '5'
				
				this.selectKey = Math.round(Math.random() * 1000)
				this.$set(this.formData, 'filterTime', '5')
				console.log('随机数', this.selectKey)
			}, 400)
			console.log("执行")
		},
		teamChange() {
			this.getFilter()
		},
		dateChange(e) {
			let that = this
			if(that.curType.name != '签名') {
				if(JSON.stringify(that.dataSource) == JSON.stringify(that.copydataSource) 
				&& JSON.stringify(that.taskImageList) == JSON.stringify(that.copytaskImageList) 
				&& JSON.stringify(that.abnormalDesc) == JSON.stringify(that.copyabnormalDesc)) {
					that.queryCurntData()
				} else {
					uni.showModal({
						content: '本页存在数据修改，是否保存并跳转？',
						success: function (res) {
							if (res.confirm) {
								that.handledataSave()
							} else if (res.cancel) {
								that.queryCurntData()
							}
						},
					});
					
				}
			} else {
				if(JSON.stringify(this.signatureList) == JSON.stringify(this.allCopySign)) {
					that.getQMList()
				} else {
					uni.showModal({
						content: '本页存在数据修改，是否保存并查询数据？',
						success: function (res) {
							if (res.confirm) {
								that.qmDataSave()
							} else if (res.cancel) {
								that.getQMList()
							}
						},
					});
					}
				}
		},
		selectChange() {
			
		},
		onClickLine(e, item, key) {
					//this.timeList = {}
					this.updataTime++
					uni.showLoading({
						title: '数据加载中！',
						 mask: true,
					});
					if(this.curType.name != '签名') {
						if(JSON.stringify(this.dataSource) == JSON.stringify(this.copydataSource)
						&& JSON.stringify(this.taskImageList) == JSON.stringify(this.copytaskImageList) 
						&& JSON.stringify(this.abnormalDesc) == JSON.stringify(this.copyabnormalDesc)) {
							this.timeList = {}
							this.curType.name = item.name;
							this.curType.key = key;
							if(item.code) {
								for(var i in item.code) {
									this.curData = i;
									break
								}
								setTimeout(()=>{
									this.timeList = item.code
									uni.hideLoading();
								}, 800)
								this.queryCurntData()
							} else {
								uni.hideLoading();
							}
						} else {
							uni.hideLoading();
							uni.showToast({
							icon: 'none',
							title: '请先提交修改数据！'
							});
						}
					} else {
						if(JSON.stringify(this.signatureList) == JSON.stringify(this.allCopySign)) {
							this.timeList = {}
							this.curType.name = item.name;
							this.curType.key = key;
							if(item.code) {
								for(var i in item.code) {
									this.curData = i;
									break
								}
								setTimeout(()=>{
									this.timeList = item.code
									uni.hideLoading();
								}, 800)
								this.queryCurntData()
							} else {
								uni.hideLoading();
							}
						} else {
							uni.hideLoading();
							uni.showToast({
							icon: 'none',
							title: '请先提交修改数据！'
							});
						}
					}
				
		},
		onClickTime(e, item, key) {
	
			this.updataTime++
			if(JSON.stringify(this.dataSource) == JSON.stringify(this.copydataSource) && JSON.stringify(this.taskImageList) == JSON.stringify(this.copytaskImageList) && JSON.stringify(this.abnormalDesc) == JSON.stringify(this.copyabnormalDesc)) {
				this.curData = key;
				this.queryCurntData()
			} else {
				uni.showToast({
				   icon: 'none',
				  title: '请先提交修改数据！'
				});
			}
		},
		//条件查询数据
		async queryCurntData() {
			const userInfor = uni.getStorageSync('userInfor');
			 const res = await getDeviceInspect({
				filterType: this.formData.filterType,
				filterTime: this.formData.filterTime,
				itemPeriod: this.curData,
				itemType: this.curType.key,
			 	orderId: this.formData.id,
			 	userId: userInfor.userId
			 });
			const { data } = res || {};
			this.dataSource = data.taskDataList
			this.taskImageList = data.taskImageList
			this.abnormalDesc = data.abnormalDesc
			this.copydataSource =  JSON.parse(JSON.stringify(data.taskDataList))
			this.copytaskImageList =  JSON.parse(JSON.stringify(data.taskImageList))
			this.copyabnormalDesc =  JSON.parse(JSON.stringify(data.abnormalDesc))
			/* this.allCopyData.dataSource = data.taskDataList
			this.allCopyData.taskImageList = data.taskImageList
			if(data.abnormalDesc !=null) {
				this.allCopyData.abnormalDesc = data.abnormalDesc
			} else {
				
			} */
			},
		formatStandardValue(value) {
			// 检查是否为0（包含字符串'0'）
			if (value === 0 || value === '0') return 0;

			// 处理其他值
			return value || '-';
		},
		// 展开/收起项目
		toggleExpand(index) {
			this.activeIndex = this.activeIndex === index ? -1 : index;
		},

		// 更新实测值
		updateMeasureValue(projectIndex, detailIndex, event) {
			const value = event.detail.value;

			// 使用Vue的set方法确保响应式更新
			this.$set(
				this.dataSource[projectIndex].detailList[detailIndex],
				'measureValue',
				value,
			);

			// 检查输入值并更新项目状态
			if (value.trim() !== '') {
				this.checkAndUpdateProjectStatus(projectIndex);
			}
		},

		// 检查并更新项目状态
		checkAndUpdateProjectStatus(projectIndex) {
			const project = this.dataSource[projectIndex];
			const completedCount = project.detailList.filter(
				(detail) => detail.measureValue?.trim() !== '',
			).length;

			// 如果需要，可以在这里更新项目状态
			// 例如：project.status = completedCount === project.detailList.length ? 'completed' : 'pending';

			// 更新已执行数量统计
			this.executedNum = this.dataSource.reduce((total, proj) => {
				return (
					total +
					proj.detailList.filter(
						(detail) => detail.measureValue?.trim() !== '',
					).length
				);
			}, 0);
		},
		//处理异常照
		abnormalPhoto(detail, projectIndex, detailIndex) {
			const deta1 = {
				fileList: detail.errImages,
				disabled: !detail.valueNumVoList[0].isEditable
			};
			uni.navigateTo({
				url:
					'/pages/deviceCheck/addPhoto/index?data=' +
					JSON.stringify(deta1),
				events: {
					addPhotoOk: (params) => {
						const { fileList } = params;
			
						// 使用Vue的set方法确保响应式更新
						/* this.$set(
							this.dataSource[projectIndex].detailList[
								detailIndex
							],
							'fileList',
							fileList,
						); */
						this.dataSource[projectIndex].errImages = fileList
					},
				},
			});
		},
		// 处理拍照
		handlePhoto(detail, projectIndex, detailIndex) {
			const deta1 = {
				fileList: this.taskImageList.imageList
			};
			uni.navigateTo({
				url:
					'/pages/deviceCheck/addPhoto/index?data=' +
					JSON.stringify(deta1),
				events: {
					addPhotoOk: (params) => {
						const { fileList } = params;

						// 使用Vue的set方法确保响应式更新
						/* this.$set(
							this.dataSource[projectIndex].detailList[
								detailIndex
							],
							'fileList',
							fileList,
						); */
						this.taskImageList.imageList = fileList
					},
				},
			});
		},

		// 处理签名
		handleSignature(detail, projectIndex, detailIndex) {
			uni.navigateTo({
				url:
					'/pages/deviceCheck/addSignature/index?data=' +
					JSON.stringify({
						...detail,
						projectIndex,
						detailIndex,
					}),
				events: {
					addOk: (params) => {
						const { fileList } = params;
						// 使用Vue的set方法确保响应式更新
						this.$set(
							this.signatureList[projectIndex],
							'signImage',
							fileList[0].url,
						);
					},
				},
			});
		},
		//获取查询条件
		async getFilter() {
			let userInfor = uni.getStorageSync('userInfor');
			let queryInfor = {
				orderId: this.formData.id,
				userId: userInfor.userId,
				teamQuery: this.teamValue
			}
			postForm('deviceInspect/infoSelect', queryInfor)
			    .then(data => {
					if(data.code == 200) {
						this.formData.filterType = data.data.filterType
						this.formData.filterTime = data.data.todayDefaultItems+''
						this.filterTime = this.formData.filterTime
						let middata = data.data.dropDownSearch
						let areaData = []
						for(var i = 0; i < middata.length; i++) {
							areaData.push({
								value: middata[i].value + '',
								text: middata[i].name
							})
							
						}
						this.dateList = areaData
						this.getList();
					} else {
						  uni.showToast({
						    icon: 'none',
						    title: data.message
						  });
					}
			    })
			    .catch(err => {
			        uni.showToast({
			           icon: 'none',
			          title: '获取数据失败，请检查接口返回'
			        });
			    });
		},
		// 获取数据
		async getList() {
			const userInfor = uni.getStorageSync('userInfor');
			 const res = await getDeviceCheckDetail({
			 	orderId: this.formData.id,
			 	userId: userInfor.userId,
				filterType: this.formData.filterType,
				filterTime: this.formData.filterTime
			 });

			const { data } = res || {};
			/* if(data.rcdjCheck.dailyScreeningTaskList && data.rcdjCheck.dailyScreeningTaskList.length>0) {
				this.dataSource = data.rcdjCheck.dailyScreeningTaskList
			} */
			const tabListRes = data?.tabList || {};
			
			/* const allTypes = [
				{ name: '日常点检', code: '1' },
				{ name: '专业点检', code: '2' },
				{ name: '6S保持', code: '3' },
				{ name: '签名', code: '4' },
			]; */
			const namelist = {
				RCDJ: '日常点检',
				SHYDJ: '6S保持',
				ZYDJ: '专业点检'
			}
			const secondTab = {
				1: '日',
				2: '周',
				3: '月',
				4: '季度',
				5: '半年'
			}
			const tabList = {}
			var current = {}
			var cuk=''
			for(var key in tabListRes) {
				var code = {}
				tabListRes[key].map(item=>{
					code[item]=secondTab[item]
				})
				tabList[key] = {
					name: namelist[key],
					code: code
				}
				if(JSON.stringify(current)=='{}'){
					cuk = key
				   current = tabList[key]
				}
			}
			tabList.qianMing = {
				name: '签名'
			}
			
			//this.onClickLine(null, current, cuk)
			this.curType.name = current.name;
			this.curType.key = cuk;
			if(current.code){
				for(var i in current.code) {
					this.curData = i;
					break
				}
			this.timeList = current.code 
			}
			this.curType.key = cuk;
			this.queryCurntData()
			this.tabList = tabList
			this.permissionType = data.permissionType
			//this.dataSource = data?.iomPrecisionManagementVoList || [];
			/* this.dataSourceMap['rcdjCheckList'] = data.rcdjCheck;
			this.dataSourceMap['zydjCheckList'] = data.zydjCheck;
			this.dataSourceMap['shydjCheckList'] = data.shydjCheck; */
			this.signatureList = data?.signatureList || [];
			this.allCopySign = JSON.parse(JSON.stringify(data.signatureList));
		},
		// 获取签名数据
		async getQMList() {
			const userInfor = uni.getStorageSync('userInfor');
			const res = await getDeviceCheckDetail({
				orderId: this.formData.id,
				userId: userInfor.userId,
				filterType: this.formData.filterType,
				filterTime: this.formData.filterTime
			});
			const { data } = res || {};
			this.signatureList = data?.signatureList || [];
			this.allCopySign = JSON.parse(JSON.stringify(data.signatureList));
		},
		// 取消
		handleStore() {
			/* this.dataSource = this.allCopyData.taskDataList
			this.taskImageList = this.allCopyData.taskImageList
			this.abnormalDesc = this.allCopyData.abnormalDesc */
			uni.navigateBack();
		},
		// 签名取消
		qianmingStore() {
			uni.navigateBack();
			//this.signatureList = this.allCopySign
		},
		handleSave() {
			const userInfor = uni.getStorageSync('userInfor');
			let savData = {
				abnormalDesc: this.abnormalDesc,
			 	orderId: this.formData.id,
			 	userId: userInfor.userId,
				permissionType: this.permissionType,
				taskDataList: this.dataSource,
				taskImageList: this.taskImageList
			}
			let that = this
			let subData = false
			let checkData = that.dataSource
			/* for(var i=0; i<checkData.length; i++) {
				if(checkData[i].valueNumVoList[0].value === '2') {
					if(checkData[i].images.length <1) {
						uni.showToast({
						   icon: 'none',
						  title: '请上传异常照片！'
						});
						subData =false
						break
					} else {
						subData =true
					}
				}
			} */
			let errors = [];
			for (const item of checkData) {
			    if (item.valueNumVoList?.[0]?.value === '2' && (!item.errImages || item.errImages.length < 1)) {
			        errors.push(item.id); // 记录异常项ID
			    }
			}
			if (errors.length > 0) {
			    uni.showToast({ icon: 'none', title: '请上传异常照片！' });
			    return false;
			} else {
				uni.showModal({
					content: '请确认，是否提交上传本次修改内容！',
					success: function (res) {
						if (res.confirm) {
							that.btnLoading = true;
							that.handleSubmit(savData)
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					},
				});
			}
		},
		// 提交
		async handleSubmit(savData) {
			const res = await submitDevicetask(
				savData
			);
			if (res.code === 200) {
				uni.showToast({ title: '提交成功', icon: 'success' });
				this.back();
			} else {
				uni.showToast({
					title: res.message || '提交失败',
					icon: 'none',
				});
			}
		},
		//切换巡检周期保存
		async handledataSave() {
			const userInfor = uni.getStorageSync('userInfor');
			let savData = {
				abnormalDesc: this.abnormalDesc,
			 	orderId: this.formData.id,
			 	userId: userInfor.userId,
				permissionType: this.permissionType,
				taskDataList: this.dataSource,
				taskImageList: this.taskImageList
			}
			const res = await submitDevicetask(
				savData
			);
			if (res.code === 200) {
				uni.showToast({ title: '提交成功', icon: 'success' });
				this.queryCurntData()
			} else {
				uni.showToast({
					title: res.message || '提交失败',
					icon: 'none',
				});
			}
		},
		//签名提交数据处理
		qianmingSave() {
			const userInfor = uni.getStorageSync('userInfor');
			let savData = {
			 	orderId: this.formData.id,
			 	userId: userInfor.userId,
				permissionType: this.permissionType,
				signatureList: this.signatureList
			}
			let that = this
			uni.showModal({
				content: '请确认，是否提交上传本次修改内容！',
				success: function (res) {
					if (res.confirm) {
						that.btnLoading = true;
						that.qianmingSubmit(savData)
					} else if (res.cancel) {
						console.log('用户点击取消');
					}
				},
			});
		},
		async qianmingSubmit(savData) {
			const res = await submitDevicesign(
				savData
			);
			if (res.code === 200) {
				uni.showToast({ title: '提交成功', icon: 'success' });
				this.back();
			} else {
				uni.showToast({
					title: res.message || '提交失败',
					icon: 'none',
				});
			}
		},
		//切换日签名提交
		async qmDataSave(){
			const userInfor = uni.getStorageSync('userInfor');
			let savData = {
			 	orderId: this.formData.id,
			 	userId: userInfor.userId,
				permissionType: this.permissionType,
				signatureList: this.signatureList
			}
			const res = await submitDevicesign(
				savData
			);
			if (res.code === 200) {
				uni.showToast({ title: '提交成功', icon: 'success' });
				this.getQMList()
			} else {
				uni.showToast({
					title: res.message || '提交失败',
					icon: 'none',
				});
			}
		},
		// 返回上一页
		back() {
			setTimeout(() => {
				this.btnLoading = false;
				uni.navigateBack();
			}, 1500);
		},
	},
};
</script>
<style>
	page {
	  overflow: hidden;
	  height: 100%;
	}
	/* 搜索框样式 */
	.custom-search-border {
		background-color: #fff;
	  border-radius: 5px; /* 圆角 */
	  margin-bottom: 10px;
	  padding: 0px 10px;
	  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); /* 阴影效果 */
	  /* border: 1px solid rgb(153, 153, 153); */
	}
	.uni-slect-view {
	    align-items: center;
		line-height: 36px;
		text-align: center;
		background-color: #fff;
	}
	.uni-select-col {
		background-color: #fff;
		}
	/* uni-form  lable样式 */
	.uni-forms-item__label {
		font-weight: 600 !important;
		width: 85px !important;
		 text-align: right !important;
		 font-size: 15px !important;
		justify-content: flex-end !important;
	}
	.uni-stat__select {
	    display: flex;
	    align-items: center;
	    width: 100%;
	    flex: 1;
	    height: 35px;
	    box-sizing: border-box;
	}
	.uni-select-col .uni-stat__select {
		border: 0px !important;
	}
	.uni-select-col .uni-select {
		border: 0px !important;
	}
	.uni-select {
		    font-size: 14px;
		    border: 1px solid #e5e5e5;
		    box-sizing: border-box;
		    border-radius: 4px;
		    padding: 0 5px;
		    padding-left: 10px;
		    position: relative;
		    display: flex;
		    -webkit-user-select: none;
		    user-select: none;
		    flex-direction: row;
		    align-items: center;
		    border-bottom: solid 1px #e5e5e5;
		    width: 100%;
		    flex: 1;
		    height: 35px;
		}
	.uni-project-item {
		background-color: #ffffff;
		border-radius: 10px;
		margin-bottom: 10px;
		padding-bottom: 15px;
		padding-top: 15px;
		padding-left: 15px;
		padding-right: 8px;
	}
	.uni-select__input-text {
		color: #6a6a6a !important;
		font-size: 12px !important;
	}
</style>
<style scoped lang="scss">
/* 样式保持不变，仅修复功能问题 */
.container {
	padding: 10px;
}


.disabled-button {
	border: 1px solid #CCCCCC !important;
	  color: #CCCCCC !important;
	  cursor: not-allowed !important;
	  background-color: #f5f5f5 !important;
}
.line-main {
	.line-box {
		display: flex;

		.line-item {
			text-align: center;
			padding: 5px;
			border-radius: 1px;
			background: #f2f2f2;
			z-index: 1;
			flex: calc(25% - 8px);

			&.active {
				background: #ffffff;
				color: #5055e6;
				border-bottom: 2px solid #5055e6;
			}
		}
	}
}
.project-list {
	margin-bottom: 20px;
	padding-bottom: 30px;
}

.project-icon {
	height: 20px;
	width: 4px;
	background: var(--primary-color);
	position: absolute;
	left: -10px;
	top: 0;
}

.project-item {
	background-color: #ffffff;
	border-radius: 10px;
	margin-bottom: 10px;
	padding-bottom: 15px;
	padding-top: 15px;
	padding-left: 15px;
	padding-right: 8px;
	//overflow: hidden;
}


.header-title {
	font-size: 16px;
	color: #000;
	font-weight: 400;
}
.project-item-left {
	font-size: 14px;
	color: #000;
	margin-top: 5px;
	color: rgb(153, 153, 153) !important;
}
.project-view-left {
	font-size: 14px;
	color: #000;
	margin-top: 5px;
}
.project-item-right {
	font-size: 14px;
	color: #000;
	margin-top: 5px;
	text-align: right !important;
}
.project-item-error {
	font-size: 14px;
	color: red;
	margin-top: 5px;
	text-align: right !important;
}
.project-code-row {
	align-items: center;
	margin-top: 5px;
	line-height: 36px;
}
.project-code-left {
	align-items: center;
	display: inline-block;
	font-size: 14px;
	color: #000;
}
.project-code-right {
	align-items: center;
	display: inline-block;
	font-size: 14px;
	color: #000;
	text-align: right !important;
}
.project-code,
.project-indicators {
	font-size: 14px;
	color: #666;
	line-height: 28px;
	margin-bottom: 3px;
}
.project-code-value {
	display: flex;
}
.project-list-value {
	display: inline-flex;
	align-items: center;
}
.project-status {
	min-width: 80px;
	text-align: center;
}

.status-button {
	background: var(--primary-color);
	color: #ffffff;
	font-size: 14px;
	padding: 4px 8px;
	border-radius: 4px;
}

.detail-panel {
	padding: 3px;
	padding-top: 0;

	.detail-group {
		padding: 12px;
		border-bottom: 1px solid #eee;
	}
}

.detail-title {
	font-weight: bold;
	margin-bottom: 10px;
	display: flex;
	align-items: center;

	.header-index {
		height: 20px;
		width: 20px;
		border-radius: 50%;
		background: #405ee0;
		color: #ffffff;
		margin-right: 8px;
		display: flex;
		align-items: center;
		justify-content: center;
		font-size: 12px;
	}
}

.detail-row {
	margin-bottom: 10px;
	color: #666;
	display: flex;
	flex-wrap: wrap;
	gap: 12px;

	.detail-row-item {
		min-width: 45%;
	}
}

.item-value {
	background: #f2f2f2;
	padding: 8px 12px;
	border-radius: 4px;
}

.input-group {
	margin: 15px 0;
	display: flex;
	align-items: center;

	.label {
		width: 100px;
		font-weight: bold;
	}

	input {
		flex: 1;
		height: 40px;
		padding: 0 10px;
		border: 1px solid #ddd;
		border-radius: 5px;
	}
}

.photo-upload {
	display: flex;
	align-items: center;
	margin-bottom: 6px;

	.label {
		width: 100px;
		font-weight: bold;
	}

	.value {
		display: flex;
		align-items: center;
	}
}

.mid-content {
	display: flex;
	justify-content: space-between;
	padding: 0 16rpx;
	padding-top: 12px;

	.left {
		display: flex;
		font-weight: 600;
		> view:first-child {
			margin-right: 16px;
		}
	}
}

.excetImage {
	width: 100px;
	height: 100px;
}

.bottom-btn {
	position: fixed;
	bottom: 0 !important;
	left: 0;
	right: 0;
	display: flex;
	justify-content: space-around;
	padding-top: 18px;
	padding-bottom: 18px;
	background: white;
	border-top: 1px solid #eee;

	button {
		font-size: 16px;
		width: 40%;
	}
}
</style>
